Skip to content

feat: add compile-time generators for views, AutoPersist, validation, and Android controls - #554

Merged
glennawatson merged 1 commit into
mainfrom
feat/aot-source-generators
Nov 21, 2026
Merged

glennawatson merged 1 commit into
mainfrom
feat/aot-source-generators

Conversation

@glennawatson

Copy link
Copy Markdown
Contributor

Summary

Adds four incremental source generators that provide compile-time, trim-safe, and Native AOT-safe replacements for reflection-based APIs being moved out of the core ReactiveUI packages.

  • Add [RegisterView] and [RegisterView<TViewModel>] to generate GeneratedViewRegistrations.RegisterGeneratedViews(this IReactiveUIBuilder) for compile-time view registration, supporting contracts and singletons without assembly scanning.
  • Add [AutoPersist] to generate a static AutoPersistMetadata property on partial [DataContract] classes capturing [DataMember] property names without runtime reflection.
  • Add [ReactiveValidation] to generate a ConfigureValidation() method that wires DataAnnotations validation attributes and [Display(Name = ...)] onto ReactiveProperty<T> properties through the reflection-free ReactivePropertyMixins.AddValidation overload.
  • Add [WireUpControls], [WireUpResource], and [IgnoreResource] in ReactiveUI.SourceGenerators.Android to generate WireUpControls() for Activity/View types and WireUpControls(View rootView) for fragments using FindViewById<T>(Resource.Id.*).
  • Update the PublicAPI.txt baselines across all target frameworks and document the new attributes in the package README.

Why

As part of reactiveui/ReactiveUI#4561, reflection-based view discovery, AutoPersist, expression-based ReactiveProperty validation, and Android ControlFetcherMixins are moving into opt-in .Unsafe packages. These generators give consumers first-class compile-time alternatives that work cleanly with trimming and Native AOT.

Refs reactiveui/ReactiveUI#4561

Breaking changes

None.

How this was verified

Unit tests verify the generated output and compilation diagnostics for all four generators, and incremental caching tests verify per-type caching for [AutoPersist], [ReactiveValidation], and [WireUpControls]. Android control wiring and ReactiveValidation compilation were exercised with in-memory stubs rather than a live Android device or an updated ReactiveUI NuGet package.

Notes for the reviewer

Checklist

  • I have read the Contribute guide
  • The PR title follows Conventional Commits
  • Tests cover this change, or the summary says why they do not
  • New or changed public API has XML documentation

… and Android controls

- Add [RegisterView] and [RegisterView<TViewModel>] to generate GeneratedViewRegistrations.RegisterGeneratedViews for IReactiveUIBuilder without assembly scanning.
- Add [AutoPersist] to generate static AutoPersistMetadata from [DataContract] and [DataMember] attributes at compile time.
- Add [ReactiveValidation] to generate ConfigureValidation() wiring DataAnnotations attributes onto ReactiveProperty<T> properties via the reflection-free AddValidation overload.
- Add [WireUpControls], [WireUpResource], and [IgnoreResource] in ReactiveUI.SourceGenerators.Android to generate compile-time FindViewById wiring.
- Update public API baselines, documentation, and unit and incremental caching tests.
@sonarqubecloud

Copy link
Copy Markdown

@codecov

codecov Bot commented Nov 21, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.86375% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 99.09%. Comparing base (2ef4c7e) to head (d06828f).

Files with missing lines Patch % Lines
...ators.Roslyn/RegisterView/RegisterViewGenerator.cs 94.40% 7 Missing ⚠️
.../ReactiveValidation/ReactiveValidationGenerator.cs 95.83% 4 Missing ⚠️
...erators.Roslyn/AutoPersist/AutoPersistGenerator.cs 96.96% 2 Missing ⚠️
...ourceGenerators/Android/WireUpResourceAttribute.cs 0.00% 2 Missing ⚠️
...s.Roslyn/WireUpControls/WireUpControlsGenerator.cs 98.95% 1 Missing ⚠️
...iveUI.SourceGenerators/RegisterViewAttribute{T}.cs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #554      +/-   ##
==========================================
- Coverage   99.15%   99.09%   -0.07%     
==========================================
  Files         475      487      +12     
  Lines       18829    19240     +411     
  Branches     2808     2893      +85     
==========================================
+ Hits        18670    19065     +395     
- Misses        159      175      +16     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@glennawatson
glennawatson merged commit af7ba4e into main Nov 21, 2026
23 of 25 checks passed
@glennawatson
glennawatson deleted the feat/aot-source-generators branch November 21, 2026 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant